package com.twu.biblioteca;

import java.io.PrintStream;
import java.util.List;

public class OutputController {
    private final PrintStream printStream;

    public OutputController(PrintStream printStream) {
        this.printStream = printStream;
    }

    public void printError(IncorrectOptionSelected incorrectOptionSelected) {
        printMessage(incorrectOptionSelected.getMessage());
    }


    private void printMessage(String message) {
        printStream.println(message);
        printStream.flush();
    }

    public void drawOptions(List<String> options) {
        StringBuilder list = new StringBuilder();
        for (int i = 0; i < options.size() ; i++) {
            list.append(i);
            list.append(". ");
            list.append(options.get(i));
            list.append("\n");

        }
        printMessage(list.toString());
    }

    public void drawMessage(String message) {
        printMessage(message);
    }
}
